package com.cheng.cms.controller;

import com.cheng.cms.domain.Property_fee;
import com.cheng.cms.service.PropertyfeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
public class PropertyfeeController {

    @Autowired
    private PropertyfeeService propertyfeeService;

    @GetMapping("/queryInfo/residentPayInfo")
    public String residentPayInfo(ModelMap modelMap){
        List<Property_fee> property_fees = propertyfeeService.selectAllPropertyfeeInfo();
        modelMap.put("propertyfee",property_fees);
        return "queryInfo/residentPaymentInfo";
    }

    @GetMapping("/queryInfo/residentPayInfo/condition")
    @ResponseBody
    public List<Property_fee> residentPayInfoByCondition(Property_fee propertyFee){
        Map<String, String> propertyFeeMap = new HashMap<>();
        if(!propertyFee.getBuildingNo().equals("全部")){
            propertyFeeMap.put("buildingNo",propertyFee.getBuildingNo());
        }
        if(!propertyFee.getRoomNo().equals("全部")){
            propertyFeeMap.put("roomNo",propertyFee.getRoomNo());
        }
        if(!propertyFee.getYear().equals("全部")){
            propertyFeeMap.put("year",propertyFee.getYear());
        }
        if(!propertyFee.getMonth().equals("全部")){
            propertyFeeMap.put("month",propertyFee.getMonth());
        }
        if(!propertyFee.getWhether().equals("全部")){
            propertyFeeMap.put("whether",propertyFee.getWhether());
        }
        return propertyfeeService.selectAllPropertyfeeInfoByCondition(propertyFeeMap);
    }
}
